home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / GLX / littleRedCap / README < prev    next >
Encoding:
Text File  |  1994-08-02  |  3.7 KB  |  75 lines

  1.  
  2.           ~4Dgifts/toolbox/src/exampleCode/GLX/littleRedCap README
  3.  
  4.  
  5.            littleRedCap: An interference checking and capping demo
  6.  
  7.       Capping is a trick employed so that we can use hollow models to 
  8.       portray solids, and is used in applications where objects could be 
  9.       clipped (such as CAD).  Interference checking is a method of 
  10.       showing the regions of intersection between two separate objects.
  11.  
  12.       This mixed model example is based on Kurt Akeley's 'cap' program.
  13.       It is by no means as robust in a demonstrational sense, meaning 
  14.       it does not read object in from a file, nor can one move around 
  15.       the clipping planes or the viewpoint.
  16.  
  17.       What it does do is to apply a clipping plane in the XY plane at 
  18.       z=0, and bring up two torii.  The clipped torii are capped using 
  19.       the same material as the rest of each respective surface.  The 
  20.       interference between the two objects is shown in red.  The yellow 
  21.       square is an outline of a plane coinciding to the arbitrary 
  22.       clipping plane 0.  The axes are drawn at the origin to indicate 
  23.       the orientation of the clipping plane.
  24.  
  25.       The capping and interference checking are both done using the 
  26.       stencil buffer.  In order for the program to run, your graphics 
  27.       needs to support stenciling.  If it doesn't the program will tell 
  28.       you so and then bail.  The good news is that Open GL requires the 
  29.       presence of at least one stencil plane, so this restriction will 
  30.       not exist when you migrate to it.
  31.  
  32.       The capping is done by rendering each object in the scene twice.  
  33.       The first time, the objects are each drawn with backfacing on
  34.       (since the capping will prevent the user from seeing the inner 
  35.       portions of the clipped objects).  Then we disable writes to the 
  36.       color and depth buffers.  We'll use the low order bit of the 
  37.       stencil buffer to determine where we've drawn part of the object. 
  38.       Then we'll draw the object again, using the stencil buffer to keep 
  39.       track of which pixels we've tried to draw something to.  Where the
  40.       value in the stencil buffer is odd, the inside of the solid was 
  41.       (rather would have been) visible.  
  42.       
  43.       After the object is rendered for the second time, we draw the 
  44.       clipping plane, using the same material property as the object's.
  45.       In order to make sure that the cap is drawn correctly, we do two 
  46.       things.  First, we shut off the clipping plane (otherwise the cap 
  47.       itself could be clipped).  Then, we transform the origin to the 
  48.       location of the clipping plane.  This prevents any problems related 
  49.       to viewer position from occuring.  For example, if the origin of 
  50.       the model view matrix were not where we expected, the cap might be 
  51.       drawn at an offset to its expected position.
  52.  
  53.       The interference checking is done after all of the objects in the 
  54.       scene are drawn with their caps.  Since the values in the stencil 
  55.       buffer are still intact, we draw a large rectangle stenciling 
  56.       those regions with pixel access counts of two or greater.  In this 
  57.       example, we draw a red rectangle, ergo the name "little red cap".
  58.  
  59.       Objects can be animated to ensure the capping and interference
  60.       checking is done in real time.
  61.  
  62.       To change the objects, their properties, or transforms, edit the 
  63.       shapes data structure in gl_interfere.c.  Refer to shapes.h for all 
  64.       available shapes.  This data structure will also take a uniform 
  65.       scaling factor if you wish to grow or shrink each shape.
  66.  
  67.       There is a known bug at startup where some or all of the inner 
  68.       window is painted red until one moves the window or presses the 
  69.       Animate button.
  70.  
  71.       Paul C. David
  72.       pcd@sgi.com
  73.       9/93
  74.  
  75.